const app = getApp()
const db = wx.cloud.database({
  env: 'cloud1-2g6vpgs796710242'
})

Page({
  data: {
    userID:"",
    cp:[],
    notice:""
  },

  onLoad: function () {
    this.gethistory()
    this.getmanagement()
  },

  getmanagement () {
    db.collection('Management')
    .doc("5e706cd764040973000033417b191c52")
    .get()
    .then(res=>{
      console.log("获取management",res)
      this.setData({
        notice:res.data.board
      })
    })
    .catch(err=>{
      console.log(err)
    })
  },

  gethistory () {
    console.log("全局获取openid",app.globalData.openid)
    db.collection('Conference')
    .where({
      _openid:app.globalData.openid
    })
    .get()
    .then(res=>{
      console.log(res)
      this.setData({
        cp:res.data
      })
    })
    .catch(err=>{
      console.log("历史数据获取失败",err)
    })
  },

  go_pd(e) {
    //'edit'表示编辑已有项目，'creator'表示新增项目
    console.log(e.currentTarget.dataset.id)
    wx.navigateTo({
      url: '../release/release?id=' + e.currentTarget.dataset.id + '&channel=' + "edit"
    })
  }

})